#!/usr/bin/env python
# -*- coding: utf-8 -*-

import rospy
from darknet_ros_msgs.msg import BoundingBoxes

class CameraModule:
    def __init__(self):
        rospy.init_node('camera_module')
        rospy.loginfo("初始化摄像头模块")

        self.bounding_boxes_subscriber = rospy.Subscriber('/darknet_ros/bounding_boxes', BoundingBoxes, self.bounding_boxes_callback)
        rospy.loginfo("订阅bounding_boxes话题")

    def bounding_boxes_callback(self, msg):
        rospy.loginfo("接收bounding_boxes话题消息")

        for box in msg.bounding_boxes:
            rospy.loginfo("目标类别: %s, Bounding Box: (%d, %d, %d, %d)", box.Class, box.xmin, box.ymin, box.xmax, box.ymax)

if __name__ == '__main__':
    try:
        camera_module = CameraModule()
        rospy.spin()
    except rospy.ROSInterruptException:
        pass
